package com.dgut.coal.service.impl;

import com.dgut.coal.dao.MarginDao;
import com.dgut.coal.entity.Margin;
import com.dgut.coal.service.MarginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MarginServiceImpl implements MarginService {
    @Autowired
    MarginDao marginDao;
    /**
     * 按参数查询保证金订单
     * @param marginType
     * @param bill_number
     * @param supplier_name
     * @param marginState
     * @return
     */
    @Override
    public List<Margin> findAllByParam(Integer marginType, String bill_number, String supplier_name, Integer marginState) {
        bill_number = "%"+bill_number+"%";
        supplier_name = "%" + supplier_name +"%";
        return marginDao.findAllByParam(marginType,bill_number,supplier_name,marginState);
    }

    /**
     * 按参数查询待审核保证金订单
     * @param bill_number
     * @param supplier_name
     * @return
     */
    @Override
    public List<Margin> findAllAuditByParam(String bill_number, String supplier_name) {
        bill_number = "%"+bill_number+"%";
        supplier_name = "%" + supplier_name +"%";
        return marginDao.findAllAuditByParam(bill_number,supplier_name);
    }

    @Override
    public Margin findMarginById(Integer marginId) {
        return marginDao.findMarginById(marginId);
    }

    @Override
    public void marginThaw(Integer marginId, String remark) {
        marginDao.marginThaw( marginId,  remark);
    }

    @Override
    public void marginAudit(Integer marginId,Integer state) {
        marginDao.marginAudit(marginId,state);
    }
}
